/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.app.model;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author Thuan
 */
@Entity
@Table(name = "Batch")
@NamedQueries({
    @NamedQuery(name = "Batch.findAll", query = "SELECT b FROM Batch b"),
    @NamedQuery(name = "Batch.findByBatchId", query = "SELECT b FROM Batch b WHERE b.batchId = :batchId"),
    @NamedQuery(name = "Batch.findByCodeToGen", query = "SELECT b FROM Batch b WHERE b.codeToGen = :codeToGen"),
    @NamedQuery(name = "Batch.findByName", query = "SELECT b FROM Batch b WHERE b.name = :name"),
    @NamedQuery(name = "Batch.findByDescription", query = "SELECT b FROM Batch b WHERE b.description = :description")})
public class Batch implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "batchId")
    private Integer batchId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 5)
    @Column(name = "codeToGen")
    private String codeToGen;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "name")
    private String name;
    @Size(max = 2147483647)
    @Column(name = "description")
    private String description;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "batch")
    private Collection<AssignmentOfBatch> assignmentOfBatchCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "batchId")
    private Collection<Student> studentCollection;
    @JoinColumn(name = "courseId", referencedColumnName = "courseId")
    @ManyToOne(optional = false)
    private Course courseId;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "batch")
    private Collection<SemesterOfBatch> semesterOfBatchCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "batch")
    private Collection<ManagerOfBatch> managerOfBatchCollection;

    public Batch() {
    }

    public Batch(Integer batchId) {
        this.batchId = batchId;
    }

    public Batch(Integer batchId, String codeToGen, String name) {
        this.batchId = batchId;
        this.codeToGen = codeToGen;
        this.name = name;
    }

    public Integer getBatchId() {
        return batchId;
    }

    public void setBatchId(Integer batchId) {
        this.batchId = batchId;
    }

    public String getCodeToGen() {
        return codeToGen;
    }

    public void setCodeToGen(String codeToGen) {
        this.codeToGen = codeToGen;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Collection<AssignmentOfBatch> getAssignmentOfBatchCollection() {
        return assignmentOfBatchCollection;
    }

    public void setAssignmentOfBatchCollection(Collection<AssignmentOfBatch> assignmentOfBatchCollection) {
        this.assignmentOfBatchCollection = assignmentOfBatchCollection;
    }

    public Collection<Student> getStudentCollection() {
        return studentCollection;
    }

    public void setStudentCollection(Collection<Student> studentCollection) {
        this.studentCollection = studentCollection;
    }

    public Course getCourseId() {
        return courseId;
    }

    public void setCourseId(Course courseId) {
        this.courseId = courseId;
    }

    public Collection<SemesterOfBatch> getSemesterOfBatchCollection() {
        return semesterOfBatchCollection;
    }

    public void setSemesterOfBatchCollection(Collection<SemesterOfBatch> semesterOfBatchCollection) {
        this.semesterOfBatchCollection = semesterOfBatchCollection;
    }

    public Collection<ManagerOfBatch> getManagerOfBatchCollection() {
        return managerOfBatchCollection;
    }

    public void setManagerOfBatchCollection(Collection<ManagerOfBatch> managerOfBatchCollection) {
        this.managerOfBatchCollection = managerOfBatchCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (batchId != null ? batchId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Batch)) {
            return false;
        }
        Batch other = (Batch) object;
        if ((this.batchId == null && other.batchId != null) || (this.batchId != null && !this.batchId.equals(other.batchId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        //return "com.app.model.Batch[ batchId=" + batchId + " ]";
        return name;
    }

}
